package com.git.bds.mr.rp.controller;

import cn.dev33.satoken.stp.StpUtil;
import com.git.bds.mr.result.R;
import com.git.bds.mr.rp.service.rolepermission.RolePermissionService;
import com.git.bds.mr.rp.service.userrole.UserRoleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author 成大事
 * @since 2022/9/18 18:16
 */
@Api(tags = "角色 权限")
@Slf4j
@Validated
@RestController
@RequestMapping("/role/permission")
@RequiredArgsConstructor(onConstructor_ = @Autowired)
public class RolePermissionController {

    private final UserRoleService userRoleService;

    private final RolePermissionService rolePermissionService;


    @ApiOperation("获得权限列表")
    @GetMapping("/getPermissionList")
    public R<List<String>> getPermissionList(){
        return R.ok(rolePermissionService.getPermissionList(StpUtil.getLoginId()));
    }

    @ApiOperation("获得角色列表")
    @GetMapping("/getRoleList")
    public R<List<String>> getRoleList(){
        return R.ok(userRoleService.getRoleList(StpUtil.getLoginId()));
    }
}
